package com.reactim.user.entity;

import jakarta.persistence.*;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedDate;
import org.springframework.data.jpa.domain.support.AuditingEntityListener;

import java.time.LocalDateTime;

/**
 * 用户隐私设置实体类
 */
@Data
@Entity
@Table(name = "user_privacy_settings")
@EntityListeners(AuditingEntityListener.class)
@EqualsAndHashCode(callSuper = false)
public class UserPrivacySetting {
    
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    private Long id;
    
    @Column(nullable = false, unique = true)
    private Long userId; // 用户ID
    
    @Enumerated(EnumType.STRING)
    @Column(nullable = false, length = 20)
    private FriendRequestPermission friendRequestPermission = FriendRequestPermission.EVERYONE;
    
    @Column(nullable = false)
    private Boolean requireVerification = true; // 是否需要验证消息
    
    @Column(nullable = false)
    private Boolean allowSearchByPhone = true; // 允许通过手机号搜索
    
    @Column(nullable = false)
    private Boolean allowSearchByEmail = true; // 允许通过邮箱搜索
    
    @Column(nullable = false)
    private Boolean allowSearchByUsername = true; // 允许通过用户名搜索
    
    @Column(nullable = false)
    private Boolean showOnlineStatus = true; // 显示在线状态
    
    @Column(nullable = false)
    private Boolean allowGroupInvite = true; // 允许群组邀请
    
    @CreatedDate
    @Column(nullable = false, updatable = false)
    private LocalDateTime createdAt;
    
    @LastModifiedDate
    @Column(nullable = false)
    private LocalDateTime updatedAt;
    
    /**
     * 好友请求权限枚举
     */
    public enum FriendRequestPermission {
        EVERYONE("所有人"),
        FRIENDS_OF_FRIENDS("朋友的朋友"),
        CONTACTS_ONLY("仅联系人"),
        NOBODY("不允许");
        
        private final String description;
        
        FriendRequestPermission(String description) {
            this.description = description;
        }
        
        public String getDescription() {
            return description;
        }
    }
}